const deleteFn = (arr: any, cat_id: number) => {
  const resultArr: any = []
  arr.forEach((item: any) => {
    if (item.cat_id !== cat_id) {
      const resultObj = {}
      for (const key in item) {
        if (Array.isArray(item[key])) {
          resultObj[key] = deleteFn(item[key], cat_id)
        } else {
          resultObj[key] = item[key]
        }
      }
      resultArr.push(resultObj)
    }
  })
  return resultArr
}

export const rightsDeleteFn = (arr: any, cat_id: number) => {
  const resultArr: any = []
  arr.forEach((item: any) => {
    if (item.id !== cat_id) {
      const resultObj = {}
      for (const key in item) {
        if (Array.isArray(item[key])) {
          resultObj[key] = rightsDeleteFn(item[key], cat_id)
        } else {
          resultObj[key] = item[key]
        }
      }
      resultArr.push(resultObj)
    }
  })
  return resultArr
}

export default deleteFn